<template>
	<view>
		<input type="text" class="a" v-model="data.username"/>
		<input type="password" class="a" v-model="data.password"/>
		<view class="a2" @tap='login'>登录</view>
	</view>
</template>

<script>
	import {doLogin} from '../../../util/user/user.js'
	export default {
		data() {
			return {
				data:''
			}
		},
		onLoad(val){
			console.log(val)
			this.data=val
		},
		methods:{
			login(val){
				console.log(this.data)
				doLogin({
					// username:this.data.username,
					// password:this.data.password
					username:this.data.username,
					password:this.data.password
				})
				.then(res=>{
					if(res.data.code === 'S'){
						uni.setStorageSync('userInfo',res.data.data)
						uni.switchTab({
							url:`/pages/user/user?username`
						})
					}
					console.log(res)
				})
			}
		}
	}
</script>

<style>
	.a{
		width: 600rpx;
		height: 100rpx;
		border-radius: 14rpx;
		background-color: #E2E2E2;
		margin: 60rpx auto;
	}
	.a2{
		width: 400rpx;
		height: 100rpx;
		background-color: #354E44;
		color: white;
		border-radius: 10rpx;
		line-height: 100rpx;
		color: white;
		margin: 60rpx auto;
		text-align: center;
	}

</style>
